#ifndef __PROTOCOL_H__
#define __PROTOCOL_H__

#include "jitqueue.h"

#ifndef VERSION_STRING
  #define VERSION_STRING "undefined"
#endif

#define DEFAULT_SERVER      127.0.0.1   /* hostname also supported */
#define DEFAULT_up_port     1780
#define DEFAULT_PORT_DW     1782
#define DEFAULT_KEEPALIVE   5           /* default time interval for downstream keep-alive packet */
#define DEFAULT_STAT        30          /* default time interval for statistics */
#define PUSH_TIMEOUT_MS     100
#define PULL_TIMEOUT_MS     100
#define GPS_REF_MAX_AGE     30          /* maximum admitted delay in seconds of GPS loss before considering latest GPS sync unusable */

#define PROTOCOL_VERSION    2           /* v1.3 */

#define PKT_PUSH_DATA   0
#define PKT_PUSH_ACK    1
#define PKT_PULL_DATA   2
#define PKT_PULL_RESP   3
#define PKT_PULL_ACK    4
#define PKT_TX_ACK      5

// #define NB_PKT_MAX      8 /* max number of packets per fetch/send cycle */

#define MIN_LORA_PREAMB 6 /* minimum Lora preamble length for this application */
#define STD_LORA_PREAMB 8
#define MIN_FSK_PREAMB  3 /* minimum FSK preamble length for this application */
#define STD_FSK_PREAMB  5

// #define STATUS_SIZE     200
#define TX_BUFF_SIZE    1024

extern int txpkjson_to_rfPara(RF_Parameters_t* tx_para,uint8_t* txpk_json);

extern void get_PULL_DATA_frame(uint8_t* buff_req);

extern void setGWNetMac(uint32_t mac_h,uint32_t mac_l);

extern int get_tx_ack(uint8_t token_h, uint8_t token_l, enum jit_error_e error,uint8_t* buf_dest);

extern int lora_pkt_fwd_init(char* server_ip,char* server_port);

extern int generate_pkt_fwd_fd(char* server_ip,char* server_port);

#endif
